// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#pragma once

class StreamOffsetToken;
class CustomWriterRuntimeData;

// This is the contract that CustomWriterManager implements to facilitate communication
// with the custom writers. It allows the custom writers to create custom data to be
// sent to the object when it is instantiated and to request a token that represents
// the node stream of an object to be later instantiated. This is implemented by the
// CustomWriterManager to allow it to properly pass any needed information to create these
// objects up as some sort of ObjectWriterResult.
struct ICustomWriterCallbacks
{
    // This will return a small token object that can be used with a CustomWriterRuntimeContext
    // to instantiate an object. For now it will be a pointer into a node stream, at some point
    // in the future it will serve as an abstraction that can be serialized by XBFv2 and point
    // into a bytecode stream.
    virtual _Check_return_ HRESULT CreateStreamOffsetToken(_Out_ StreamOffsetToken* pToken) = 0;

    // Once a custom writer has generated a blob of custom data for a certain object
    // at the EndObject call it is expected to call back to the CustomWriterManager and hand
    // off a pointer to the optimized data structure it created, which will in turn be saved
    // into the generated bytecode.
    virtual _Check_return_ HRESULT SetCustomWriterRuntimeData(_In_ std::unique_ptr<CustomWriterRuntimeData> runtimeData) = 0;

    // TODO: New comment
    virtual void SetAllowProcessStartObjectByCustomWriter(bool allow) = 0;
};

